<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center choosework_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub choosework_fd0_0'>
          <view class='flex flex-wrap align-center choosework_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  choosework_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='choosework_fd0_0_c1_c0'>工作类型</text>
          </view>
          <view class='flex flex-wrap align-center justify-end choosework_fd0_0_c0' @click.stop="submit">
            <text class='choosework_fd0_0_c2_c0'>确定</text>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout">
        <view class='flex flex-direction flex-wrap align-stretch flex-sub choosework_fd1_0'>
          <text class="text-red text-weight-600 text-lg">可多选</text>
          <view class='flex flex-wrap align-center'>
            <view class='flex flex-wrap align-center choosework_fd1_0_c1_c0' v-for="(itemA,indexA) in chooseArr"
              :key="indexA">
              <text>{{itemA.name}}</text>
              <image @click="delArr(itemA,indexA)" class='choosework_fd1_0_c1_c0_c1' mode="aspectFit"
                :src='STATIC_URL+"153.png"'></image>
            </view>
          </view>
        </view>
        <view class=' align-center'>
          <view class='flex flex-wrap align-center justify-between flex-sub choosework_fd1_1_c0'
            v-for="(item,index) in workType" :key="index" @click="chooseItem(item)">
            <text>{{item.name}}</text>
            <view class='flex flex-wrap align-center'>
              <image class='choosework_fd1_1_c0_c1_c0' v-if="item.check" mode="aspectFit" :src='STATIC_URL+"155.png"'>
              </image>
              <image class='choosework_fd1_1_c0_c1_c0' v-else mode="aspectFit" :src='STATIC_URL+"154.png"'></image>
            </view>
          </view>
        </view>
        <!-- <view class='flex flex-wrap align-center choosework_fd1_2'>
          <benben-input type="text" :placeholder="`请输入（选填）`" confirm-type="done" :maxlength="-1" :adjust-position='true'
            v-model="keyword" @confirm="getData" placeholder-style="color:#999;font-size:28rpx" />
        </view> -->
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  export default {
    components: {},


    data() {
      return {
        workType: [],
        chooseArr: [],
        postcate_id: '',
        keyword: ''
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },

    },
    watch: {},
    onLoad(options) {
      this.postcate_id = options.postcate_id
      this.getData()
    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {

    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {

    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      chooseItem(item) {
        item.check = !item.check
        this.chooseArr = this.workType.filter(item => item.check == true)
      },
      delArr(item, index) {
        item.check = false
        this.chooseArr.splice(index, 1)
      },
      getData() {
        this.$api.post(global.apiUrls.post65d30e6e31cd9, {
          id: this.postcate_id,
          keyword: this.keyword
        }).then(res => {
          if (res.data.code == 1) {
            this.workType = res.data.data
            this.chooseArr = this.workType.filter(item => item.check == true)
          }
        })
      },
      submit() {
        if (this.chooseArr.length == 0) {
          this.$message.info('请选择工作类型')
          return
        }
        uni.$emit('workType', this.chooseArr)
        uni.navigateBack()
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: var(--benbenbgColor1);
    background-size: 100% auto;
  }

  .choosework_flex_0 {
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .choosework_fd0_0_c2_c0 {
    color: var(--benbenFontColor4);
  }

  .choosework_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .choosework_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .choosework_fd0_0_c0 {
    width: 120rpx;
  }

  .choosework_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .choosework_fd1_2 {
    background: #F8F8F8;
    border-radius: 32rpx 32rpx 32rpx 32rpx;
    width: 710rpx;
    height: 64rpx;
    padding: 0rpx 12rpx 0rpx 24rpx;
    margin: 32rpx auto 32rpx auto;
    line-height: 64rpx;
  }

  .choosework_fd1_1_c0_c1_c0 {
    width: 36rpx;
    height: 36rpx;
  }

  .choosework_fd1_1_c0 {
    padding: 24rpx;
  }

  .choosework_fd1_0_c1_c0_c1 {
    width: 32rpx;
    height: 32rpx;
    position: absolute;
    top: -10rpx;
    right: -20rpx;
  }

  .choosework_fd1_0_c1_c0 {
    border: 1px solid var(--benbenbdColor1);
    background: rgba(250, 250, 250, 1);
    background-size: 100% auto;
    padding: 6rpx 10rpx 6rpx 10rpx;
    border-radius: 44rpx;
    margin: 24rpx 12rpx 0rpx 0rpx;
    position: relative;
  }

  .choosework_fd1_0 {
    background: rgba(246, 247, 249, 1);
    background-size: 100% auto;
    padding: 24rpx;
  }
</style>
